<?php
defined( 'BASEPATH' ) or exit( 'No direct script access allowed' );
class MY_URI extends CI_URI
{
    public $logic_group = '';
    protected function _set_uri_string($str)
    {
        $logic_groups = $this->config->item( 'logic_groups' );
        if (isset( $logic_groups ) && is_array( $logic_groups ))
        {
            if ($this->config->item( 'enable_query_strings' ) !== TRUE)
            {
                foreach ( $logic_groups as $group )
                {
                    $group = trim( strtolower( $group ), '/' );
                    if (strpos( strtolower( $str ), $group ) === 0)
                    {
                        $this->logic_group = $group;
                        $str = ( string ) substr( $str, strlen( $group ) );
                        break;
                    }
                }
            }
            else if (isset( $_GET[$this->config->item( 'group_trigger' )] ))
            {
                foreach ( $logic_groups as $group )
                {
                    $group = trim( strtolower( $group ), '/' );
                    if ($_GET[$this->config->item( 'group_trigger' )] === $group)
                    {
                        $this->logic_group = $group;
                        break;
                    }
                }
            }
        }
        parent::_set_uri_string( $str );
    }
}